//
//  UFOSXPPicPageViewController.m
//  unrivalledForUniverse
//
//  Created by dllo on 16/1/18.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "UFOSXPPicPageViewController.h"
#import "RGCardViewLayout.h"
#import "UFOPicDetailCollectionCell.h"
#import "UFOSXPPicPageListModel.h"
@interface UFOSXPPicPageViewController () <UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, retain) UICollectionView *picDetailCollectionV;
@end

@implementation UFOSXPPicPageViewController

- (void)dealloc
{
    [_picDataArr release];
    [_picDetailCollectionV release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self createBackImageView];
    [self createCollectionView];
}

// 背景
- (void)createBackImageView
{
    UIImageView *imageV = [[UIImageView alloc] initWithFrame:self.view.bounds];
    imageV.image = [UIImage imageNamed:@"q=20120905_205823_618bf8407e819127_o.jpg"];
    imageV.userInteractionEnabled = YES;
    [self.view addSubview:imageV];
    [imageV release];
}

// 创建collectionView
- (void)createCollectionView
{
    RGCardViewLayout *layout = [[[RGCardViewLayout alloc] init] autorelease];
    
    self.picDetailCollectionV = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
    self.picDetailCollectionV.backgroundColor = [UIColor clearColor];
    self.picDetailCollectionV.pagingEnabled = YES;
    self.picDetailCollectionV.delegate = self;
    self.picDetailCollectionV.dataSource = self;
    
    [self.view addSubview:self.picDetailCollectionV];
    [self.picDetailCollectionV release];
    
    [self.picDetailCollectionV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(self.view);
        
    }];
    
    [self.picDetailCollectionV registerClass:[UFOPicDetailCollectionCell class] forCellWithReuseIdentifier:@"picDetailCell"];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 1;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return  self.picDataArr.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UFOPicDetailCollectionCell *cell = (UFOPicDetailCollectionCell  *)[collectionView dequeueReusableCellWithReuseIdentifier:@"picDetailCell" forIndexPath:indexPath];
    UFOSXPPicPageListModel *model = [self.picDataArr objectAtIndex:indexPath.section];
    [cell.imageV sd_setImageWithURL:[NSURL URLWithString:model.diy]];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
